﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="设备内部转移.aspx.cs" Inherits="syc.Jidong.设备内部转移" %>
<html>
<head>
<title></title>
</head>
<style>
div.autofinish{position:absolute; z-index:2;border:solid 1px #ccaa88;background-color:#ffffff;padding:5px;font-size:14px;color:#ff0000;}
#BianHao{background-image:url(/images/bmback.gif); background-repeat:no-repeat;}
</style>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
 
SelectCommand="select @编码=编码,@名称=isnull(名称,0),@型号=isnull(型号,'')
,@总成本=isnull(总成本,0),@投产日期=投产日期,@折旧年限=isnull(折旧年限,0)
,@出厂编号=isnull(出厂编号,''),@出厂日期=出厂日期,@安装地点=isnull(安装地点,'')
from 设备台账 where ID=@ID" onselected="SqlDataSource1_Selected"
UpdateCommand="if exists (select ID from 设备台账 where ID=@ID and 编码=@编码)
begin
update 设备台账 set 编码=@新编码,安装地点=@新地点 where ID=@ID and 编码=@编码;
insert into 设备转移单(单据号,日期,台账ID,编码1,编码2,原址,备注)values(@单据号,@日期,@ID,@编码,@新编码,@安装地点,@备注);
end
"
>
<SelectParameters>
<asp:Parameter Name="ID" Size="4" DbType="Int32"/>
<asp:Parameter Name="编码" DbType="AnsiStringFixedLength"  Size="18" Direction="Output"/>
<asp:Parameter Name="名称" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="型号" DbType="AnsiString" Size="20" Direction="Output"/>

<asp:Parameter Name="总成本" DbType="Currency" Size="9" Direction="Output"/>
<asp:Parameter Name="投产日期" DbType="Date"  Size="3" Direction="Output"/>
<asp:Parameter Name="折旧年限" DbType="Int16"  Size="2" Direction="Output"/>

<asp:Parameter Name="出厂编号" DbType="String"  Size="20" Direction="Output"/>
<asp:Parameter Name="出厂日期" DbType="String"  Size="40" Direction="Output"/>
<asp:Parameter Name="安装地点" DbType="String"  Size="40" Direction="Output"/>
</SelectParameters>

<UpdateParameters>
<asp:Parameter Name="ID" Size="4" DbType="Int32"/>
<asp:Parameter Name="编码" DbType="AnsiStringFixedLength"  Size="18"/>
<asp:Parameter Name="新编码" DbType="AnsiStringFixedLength"  Size="18"/>
<asp:Parameter Name="安装地点" DbType="String"  Size="40"/>
<asp:Parameter Name="新地点" DbType="String"  Size="40"/>

<asp:Parameter Name="单据号" DbType="AnsiString" Size="10"/>
<asp:Parameter Name="日期" DbType="Date"  Size="3"/>
<asp:Parameter Name="备注" DbType="String"  Size="100"/>
</UpdateParameters>
</asp:SqlDataSource>

<asp:Label ID="BillID" runat="server" Text="" Visible="false"></asp:Label>
<div id="wintop" class="wintop">固定资产内部转移</div>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">
    <asp:Button ID="Button_Save" runat="server" Text="确认转移" UseSubmitBehavior="false" 
    OnClientClick="if(!confirm('确认要转移吗？'))return(false);" 
        CssClass="button" onclick="Button_Save_Click"  />
    <input type="button" value="关 闭" class="button" onclick="parent.swin2_close();" />
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel">
<table border="1" style="border-collapse:separate;font-size:14px;">
	<tr height="30">
		<td width=80 align="right">原编号:</td>
		<td width=160><asp:Label ID="BianHao0" runat="server" Text=""></asp:Label></td>
		<td width=80 align="right">资产名称:</td>
		<td width=160><asp:Label ID="MingCheng" runat="server" Text=""></asp:Label>　</td>
		<td width=80 align="right">规格型号:</td>
		<td width=160><asp:Label ID="XingHao" runat="server" Text=""></asp:Label>　</td>
	</tr>
	<tr height="30">
	    <td align="right">原 值:</td>
		<td><asp:Label ID="YuanZhi" runat="server" Text=""></asp:Label>元</td>
	    <td align="right">投产日期:</td>
		<td><asp:Label ID="Date1" runat="server" Text=""></asp:Label>　</td>
	    <td align="right">折旧年限:</td>
		<td><asp:Label ID="NianXian" runat="server" Text=""></asp:Label>　</td>
	</tr>
	
	<tr height="30">
	    <td align="right">出产编号:</td>
		<td><asp:Label ID="ChuChangBH" runat="server" Text=""></asp:Label>　</td>
	    <td align="right">出厂日期:</td>
		<td><asp:Label ID="Date2" runat="server" Text=""></asp:Label>　</td>
	    <td align="right">安装地点:</td>
		<td><asp:Label ID="DiDian0" runat="server" Text=""></asp:Label>　</td>
	</tr>
	
	<tr height="30">
		<td align="right">新编号:</td>
		<td><asp:TextBox ID="BianHao" runat="server" CssClass="textbox" Width="100%" ></asp:TextBox></td>
		<td align="right">转移日期:</td>
		<td><asp:TextBox ID="Date3" runat="server" CssClass="textbox" Width="120"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date3').value, document.getElementById('Date3'));" /></td>
		<td align="right">新安装地点:</td>
		<td><asp:TextBox ID="DiDian" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
	</tr>
	<tr height="30">
		<td align="right">内移字号:</td>
		<td><asp:TextBox ID="ZiHao" runat="server" CssClass="textbox" Width="120" ></asp:TextBox></td>
		<td align="right">备 注:</td>
		<td colspan="3"><asp:TextBox ID="BeiZhu" runat="server" CssClass="textbox" Width="368"></asp:TextBox></td>
	</tr>
</table>

</asp:Panel>

<asp:Panel ID="Panel_Msg" runat="server" CssClass="panel2">
    <asp:Label ID="Message" runat="server" Text="" CssClass="prompt"></asp:Label>
</asp:Panel>

</form>

<script>
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName != "INPUT" || tag.className != "textbox") return;
        if (tag.id == "BeiZhu") return;
        if(e.keyCode==13)e.keyCode = 9;
    }

    function AutoFinish(id, targetId) {

        //生成容器
        var div = document.createElement("DIV");
        div.id = id;
        div.className = "autofinish";
        div.style.display = "none";
        document.body.appendChild(div);

        var target = document.getElementById(targetId);

        var start = function() {
            if (document.activeElement != target || target.value == "") return;
            doGet();
        }

        if (target.addEventListener) {
            target.addEventListener("input", start, false);
        }
        else {
            target.onpropertychange = start;
        }

        target.onblur = function() {
            setTimeout("document.getElementById('" + id + "').style.display = 'none'", 200);
        };

        //返回数据处理函数
        var onreturn = function(http) {
            if (http.status != 200) {
                alert("服务器错误: " + http.status + " " + http.statusText);
                return;
            }
            var div = document.getElementById(id);
            var tag = document.getElementById(targetId);
            div.style.top = (getObjectTop(tag) + tag.clientHeight + 10) + "px";
            div.style.left = (getObjectLeft(tag)) + "px";
            div.style.display = "";
            div.innerHTML = "<pre style='font-size:14px;'>" + http.responseText + "</pre>";
        };

        var doGet = function() {
            var s = target.value.replace(/^\s+/, "").replace(/\s+$/, "");
            if (s == "" || s.length % 2==1) return;
            var request = createRequest(onreturn);
            request.open("GET", encodeURI("/jidong/设备编码提示.ashx?s=" + target.value), true);
            request.send(null);
        };
    }

    AutoFinish("aaaa", "BianHao");

    function makecalendar(d, o) {
        obj = o;
        idate = makedate(d);
        cdate = new Date(idate.getFullYear(), idate.getMonth(), 1);
        ds.style.left = (getObjectLeft(o) + 0) + "px";
        ds.style.top = (getObjectTop(o) - 130) + "px";
        ds.style.display = 'block';
        showcalendar();
    }
</script>
</body>
</html>
